package org.example.Thread01;

import java.util.Scanner;

public class Dome_Thread08 {
    static volatile int flag=0;
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            System.out.println(Thread.currentThread().getName()+"线程启动...");
            while(flag==0){
                //一直循环
            }
            System.out.println(Thread.currentThread().getName()+"线程退出...");
        },"t1");
        t1.start();
        Thread t2 = new Thread(()->{
            System.out.println(Thread.currentThread().getName()+"线程启动...");
            Scanner in=new Scanner(System.in);
            System.out.println("请输入一个非零的整数：");
            flag=in.nextInt();
            System.out.println(Thread.currentThread().getName()+"线程退出...");
        },"t2");
        t2.start();

    }
}
